<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>一个区间内所有数乘积的缩写</title>
</head>
<body>
  <script>
    function fn(left, right) {
      let zero = 0;
      // 计算后缀，并统计末位 0 的个数
      let suf = 1;
      let flag = true;
      for (let i = left; i < right + 1; i++) {
        suf *= i;
        while (suf % 10 == 0) {
          zero++;
          suf /= 10;
        }
        if (suf > 10000000000) {
          flag = false;
          suf %= 10000000000;
        }
      }
      if (flag) {
        return suf + "e" + zero;
      }
      // 计算前缀
      let pref = 1;
      for (let i = left; i < right + 1; i++) {
        pref *= i;
        while (pref > 1000000000000) pref /= 10;
      }
      var x = String.valueOf(pref), y = String.valueOf(suf);
      let n = y.length() - 5;
      return x.substring(0, 5) + "..." + y.substring(n) + "e" + zero;
    }
    console.log(fn(1, 4))
  </script>
</body>

</html>